function [ o, b ] = assemblyBoundaryVector( mesh, deform )
%ASSEMBLYBOUNDARYVECTOR Summary of this function goes here
%   Detailed explanation goes here

nTri = size(mesh.f, 1);
nVer = size(mesh.v, 1);

o = ones(3*nVer, 1);
o(1:3:nVer*3) = deform.v(:, 1) - mesh.v(:, 1);
o(2:3:nVer*3) = deform.v(:, 2) - mesh.v(:, 2);
o(3:3:nVer*3) = deform.v(:, 3) - mesh.v(:, 3);

b = zeros(3*nTri, 1);

for i = 1 : nTri
   i1 = mesh.f(i, 1);
   i2 = mesh.f(i, 2);
   i3 = mesh.f(i, 3);
   
   b(3*i-2) = (o(3*i1-2) + o(3*i2-2) + o(3*i3-2)) / 3.0;
   b(3*i-1) = (o(3*i1-1) + o(3*i2-1) + o(3*i3-1)) / 3.0;
   b(3*i-0) = (o(3*i1-0) + o(3*i2-0) + o(3*i3-0)) / 3.0;
end

end

